﻿@using System.Web.Optimization
@using Res = ViewRes.User.FavoriteSongsStrings;
@using SharedRes = ViewRes.SharedStrings;
@inherits VocaDb.Web.Code.VocaDbPage<VocaDb.Web.Models.User.FavoriteSongs>

@{
    PageProperties.Title = "Songs rated by " + Model.User.Name;
	ViewBag.Parents = new[] {
		Html.ActionLink(Model.User.Name, "Details", "User", new {id = Model.User.Id}, null)
	};	
}

@{ Html.RenderPartial("Partials/_RatedSongs"); }

@section BodyScripts {
	<link rel="stylesheet" href="@Url.Content("~/Content/Styles/songlist.css")" type="text/css" />
	<script type="text/javascript" src="https://www.youtube.com/iframe_api"></script>
	@Scripts.Render("~/bundles/User/RatedSongs")

	<script type="text/javascript">

		$(function () {

			moment.locale('@Culture');
			var cultureCode = '@UICulture';
			var languageSelection = '@UserContext.LanguagePreference';
			var loggedUserId = @Model.User.Id;
			var sort = @ToJS(Model.Sort.HasValue ? Model.Sort.ToString() : null);
			var groupByRating = @ToJS(Model.GroupByRating);

			var rootPath = '@RootPath';
			var urlMapper = new vdb.UrlMapper(rootPath);
			var repoFactory = new vdb.repositories.RepositoryFactory(urlMapper, @LanguagePreferenceInt);
			var userRepo = repoFactory.userRepository();
			var artistRepo = repoFactory.artistRepository();
			var songRepo = repoFactory.songRepository();
			var resourceRepo = repoFactory.resourceRepository();
			var pvPlayersFactory = new vdb.viewModels.pvs.PVPlayersFactory($("#pv-player-wrapper"));

			var vm = new vdb.viewModels.user.RatedSongsSearchViewModel(urlMapper, userRepo, artistRepo, songRepo, resourceRepo, languageSelection, loggedUserId, cultureCode,
				sort, groupByRating, pvPlayersFactory, true);
			ko.applyBindings(vm);

		});

	</script>

}